1 module gamescript.entry; 2 import hip.api; 3 4 /** 5 * Call `dub` to generate the DLL, after that, just execute `dub -c run` for starting your project 6 */ 7 class MainScene : AScene, IHipPreloadable 8 { 9 mixin Preload; 10 IHipFont bigFont, smallFont; 11 /** Constructor */ 12 override void initialize() 13 { 14 Viewport vp = getCurrentViewport(); 15 vp.setBounds(0, 0, 800, 600); 16 setViewport(vp); 17 18 smallFont = HipDefaultAssets.getDefaultFontWithSize(20); 19 bigFont = HipDefaultAssets.getDefaultFontWithSize(64); 20 } 21 /** Called every frame */ 22 override void update(float dt) 23 { 24 if(HipInput.isMouseButtonJustPressed(HipMouseButton.left)) 25 { 26 logg("You just clicked me!"); 27 } 28 29 if(HipInput.isKeyJustPressed(HipKey.ENTER)) 30 { 31 logg("Don't press ENTER!"); 32 } 33 } 34 /** Renderer only, may not be called every frame */ 35 override void render() 36 { 37 fillRectangle(0, 0, 200, 200, HipColor.red); 38 fillRectangle(0, 0, 100, 100, HipColor.green); 39 40 //Use a non GC allocating string on render (String) for drawing the mousePosition 41 import hip.util.string; 42 float[2] mousePos = HipInput.getWorldMousePosition(); 43 setFont(smallFont); 44 String s = String(mousePos); 45 drawText(s.toString, cast(int)mousePos[0], cast(int)mousePos[1]); 46 47 48 49 ////////////////////////Higher Level//////////////////////// 50 setGeometryColor(HipColor.white); 51 setFont(null); 52 drawText("Hello World Test Scene (Default Font)", 300, 280, HipColor.white, HipTextAlign.LEFT, HipTextAlign.TOP); 53 fillRectangle(300, 300, 100, 100); 54 55 drawText("Null Textures uses that sprite over here", 300, 480, HipColor.white, HipTextAlign.LEFT, HipTextAlign.TOP); 56 drawTexture(null, 300, 500); 57 58 } 59 /** Pre destroy */ 60 override void dispose() 61 { 62 63 } 64 65 void onResize(uint width, uint height){} 66 } 67 68 mixin HipEngineMain!MainScene;